package com.gorillalogic.scrummonkey.dms {
	import mx.rpc.AsyncToken;

	public class ProjectService extends _Super_ProjectService {
		public static var service:ProjectService = new ProjectService();

		public override function deleteProject(project:Project):AsyncToken {
			//first, delete all objectives
			var objectives:Array = project.objectives.toArray();
			project.objectives.removeAll();
			objectives.forEach(
				function(o:Objective, idx:int, items:Array):void {
					ObjectiveService.service.deleteObjective(o);
				});

			//second, delete all releases (which first deletes all iterations under release)
			var releases:Array = project.releases.toArray();
			project.releases.removeAll();
			releases.forEach(
				function(release:Release, index:int, releases:Array):void {
					ReleaseService.service.deleteRelease(release);
				});

			//lastly, delete the project
			return super.deleteProject(project);
		}
	}
}
